package com.hmall.common.client;

import com.hmall.common.config.DefaultFeignConfiguration;
import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "itemservice", configuration = DefaultFeignConfiguration.class)
public interface ItemClient {

    @GetMapping("/item/list")
    PageDTO<Item> getItems(@RequestParam("page") Integer page,
                           @RequestParam("size") Integer size);

    /**
     * 根据商品Id查询商品
     *
     * @param id
     * @return
     */
    @GetMapping("/item/{id}")
    Item getItemById(@PathVariable("id") Long id);

    /**
     * 增减库存数量
     */
    @PutMapping("/item/stock/{itemId}/{num}")
    Long modifyStock(@PathVariable("itemId") Long itemId, @PathVariable("num") Integer num);
}
